<!-- 首页 -->
<template>
	<view class="components" v-if="open">
		<view class="content-box flex flex-direction align-center">
			<view class="title">
				<text>{{title}}</text>
			</view>
			<view class="m-t10 text-center">
				<slot>
					<text class="line-height24 f-s14 f-w400">{{content}}</text>
				</slot>
			</view>
			<view class="m-t16 flex justify-center">
				<view class="cancel-btn" @click="handleCancel" v-if="cancelBtn">
					<text>{{cancelText}}</text>
				</view>
				<view class="confirm-btn" @click="handleConfirm">
					<text>{{confirmText}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "modal",
		props: {
			show: {
				type: Boolean,
				default: false
			},
			title: {
				type: String,
				default: '提示'
			},
			content: {
				type: String,
				default: ''
			},
			cancelText: {
				type: String,
				default: '取消'
			},
			confirmText: {
				type: String,
				default: '确认'
			},
			cancelBtn:{
				type:Boolean,
				default:true
			}
		},
		data() {
			return {
				open: false
			}
		},
		watch: {
			show: {
				handler(val) {
					this.open = val
				}
			}
		},
		methods: {
			handleCancel() {
				this.$emit('cancel')
				this.$emit('update:show', false)
			},
			handleConfirm() {
				this.$emit('confirm')
				this.$emit('update:show', false)
			},
		}
	}
</script>

<style scoped lang="scss">
	.components {
		width: 100vw;
		height: 100vh;
		position: fixed;
		top: 0;
		left: 0;
		background-color: rgba(0, 0, 0, 0.7);
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 9999;

		.content-box {
			width: 560rpx;
			background: #FFFFFF;
			border-radius: 40rpx;
			padding: 40rpx;

			.title {
				font-weight: 600;
				font-size: 34rpx;
				color: #121924;
				line-height: 48rpx;
			}

			.cancel-btn {
				width: 228rpx;
				height: 72rpx;
				background-color: #DDE0E6;
				border-radius: 8rpx;
				font-weight: 500;
				font-size: 32rpx;
				color: #202020;
				line-height: 72rpx;
				text-align: center;
			}

			.confirm-btn {
				width: 228rpx;
				height: 72rpx;
				background: #202020;
				border-radius: 8rpx;
				font-weight: 600;
				font-size: 32rpx;
				color: #FFFFFF;
				line-height: 72rpx;
				margin-left: 24rpx;
				text-align: center;
			}
		}
	}
</style>